//
// Copyright (c) Microsoft Corporation.  All rights reserved.
//
//
// Use of this sample source code is subject to the terms of the Microsoft
// license agreement under which you licensed this sample source code. If
// you did not accept the terms of the license agreement, you are not
// authorized to use this sample source code. For the terms of the license,
// please see the license agreement between you and Microsoft or, if applicable,
// see the LICENSE.RTF on your install media or the root of your tools installation.
// THE SAMPLE SOURCE CODE IS PROVIDED "AS IS", WITH NO WARRANTIES.
//
/*++
THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
PARTICULAR PURPOSE.

Module Name: wbttskmn.h

Abstract:

Notes:
--*/


#ifndef __WBTTSKMN_H__
#define __WBTTSKMN_H__

#include "wbtcnctn.h"

#define NUM_TASKMAN_CONTROL_WINDOWS       9
#define NUM_TABS                          2
#define TASKMAN_TAB1                      0
#define TASKMAN_TAB2                      1

#define LV_COLUMNWIDTH_CHANGED            WM_USER + 0x0300
#define TASKMAN_SETBUTTON_STATE           WM_USER + 0x0301
#define TASKMAN_SETBUTTON_FOCUS           WM_USER + 0x0302
#define TASKMAN_CHANGE_TAB                WM_USER + 0x0303

/*++

--*/


typedef struct
tagEndTaskDlgData {        
    HANDLE hProcess;
    HANDLE hEndEvent;
    LPWSTR lpszDesc;
    HWND hwndEndTaskDlg;
} END_TASK_DLG_DATA, *PEND_TASK_DLG_DATA;

/*++

--*/


typedef struct
tagDlgHdr {        
    HWND hwndTabControl;
    HWND hwndTab[NUM_TABS];
    DLGTEMPLATE* dlgRes[NUM_TABS];
    RECT rcTabControl; 
} DLGHDR, *PDLGHDR;  



/*++

--*/


typedef class 
CWbtTaskman {
   
public:

   HWND hwnd;        
        
        CWbtTaskman();
       ~CWbtTaskman();
   BOOL InitInstance(HINSTANCE hInstance, INT iStartupFlag);
   VOID ProcessAutostart();
   
private:
   //-------------AAS-----------
   BOOL  bDemoMode;
   BOOL  bRunned;
   BOOL  bWeShouldRun;
   BOOL  bWeShouldRunVNC;
   TCHAR lpszRunAtStartup[255];
   TCHAR lpszRunAtStartupArgs[255];
   static DWORD WINAPI  LaunchPowerOff(LPVOID lpvThreadParam); 

   VOID  LoadRunAtStartupSettingsDynamic();
   VOID  RunAtStartup();
   //-------------AAS-----------

   BOOL  bEndSessionInProgress;
   BOOL  bRestart;
   HWND  hwndTaskmanControl[NUM_TASKMAN_CONTROL_WINDOWS];
   HWND  hwndDesktop;
   INT   nWebConnectionIndex;
   
   DWORD dwWatchdogThreadId;
   DWORD dwTerminalHelperPID;
   TCHAR lpszStatus[2][48];
   TCHAR lpszStartup[3][48];   
   HANDLE hWatchdogThread;   
   static HINSTANCE hInstance;   
   PCONNECT_LIST pclist;

   struct {
      TCHAR szTaskmanTitle[MAX_PATH];
      DWORD dwEndTaskTimeOut;
   } shellcfg;
   
   
   BOOL ClientListInit(PCONNECT_LIST connections, HWND hwndDlg);
   VOID ConnectionActivate(INT item);
   BOOL ConnectionAdd(INT index);
   BOOL ConnectionDelete(INT item);   
   BOOL ConnectionEdit(INT item);   
   VOID ConnectionEnd(INT item);
   VOID ConnectionSetDefault(INT index, BOOL autostart);
   VOID GotoSessionHome();
   VOID GotoSessionNext();
   VOID GotoSessionPrev();
   VOID HandleHotkeyMsg(INT idHotKey, UINT fuModifiers, UINT uVirtKey);
   BOOL LaunchHelperApp(DWORD dwHelperType, LPWSTR &lpszAppName, LPWSTR &lpszCmdLine, INT index);
   VOID LaunchHelperAppPostProcess(DWORD dwHelperType, DWORD dwProcessExitCode, INT index);
   VOID LaunchNewSession(PCONNECT_DATA cdata);   
   BOOL Listview1Init(HWND hwndDlg);
   VOID Listview1SetButtonState();
   BOOL Listview2Init(HWND hwndDlg);    
   INT  Listview2GetButtondId(HWND hwndFocus);
   VOID Listview2SetButtonState();
   VOID Listview2SetButtonFocus(INT iButton);
   VOID Listview2SetButtonDefault(UINT nButton);
   BOOL ListviewDeleteItems(HWND hwndLV);
   INT  ListviewGetSelectedItem(HWND hwndLV, UINT mask);
   VOID ListviewSetSelectedItem(HWND hwndLV, INT item, UINT mask);    
   BOOL ListviewInsertItems(HWND hwndLV);
   VOID ListviewUpdate();
   VOID ListviewUpdate(INT item);
   BOOL LoadSettingsStatic();
   VOID LoadSettingsDynamic();
   BOOL TaskmanEnable(BOOL bEnable);
   BOOL TaskmanDialogInit();
   VOID TaskmanSetCursor(LPCTSTR lpCursorName);  
   VOID TaskmanShow();  
   VOID TaskmanShowTab(INT iTab);
   VOID TaskmanShowWindow(LPARAM lParam);
   VOID TaskmanSetLastPID(PCONNECT_DATA cdata);
   INT  GetWebConnectionIndex() { return nWebConnectionIndex; }

   DLGTEMPLATE* WINAPI DoLockDlgRes(LPCWSTR lpszResName);

   static DWORD WINAPI  EndSessionThread(LPVOID lpvThreadParam);   
   static DWORD WINAPI  EndTaskDlgWaitThrd(LPVOID lpvThreadParam);
   static DWORD WINAPI  LaunchHelperAppThread(LPVOID lpvThreadParam);   
   static DWORD WINAPI  LaunchNewSessionThread(LPVOID lpvThreadParam);         
   static BOOL  WINAPI  Listview1Notify(HWND hwnd,UINT uMsg, WPARAM wParam, LPARAM lParam);
   static BOOL  WINAPI  Listview2Notify(HWND hwnd,UINT uMsg, WPARAM wParam, LPARAM lParam);   
   static BOOL  WINAPI  TabNotify(HWND hwnd,UINT uMsg, WPARAM wParam, LPARAM lParam);         
   static DWORD WINAPI  TaskmanWatchdogThread(LPVOID lpvThreadParam);   
   
   static BOOL CALLBACK EndTaskDlg(HWND hwnd,UINT uMsg, WPARAM wParam, LPARAM lParam);   
   static BOOL CALLBACK SelectClientDlgProc(HWND hwnd,UINT uMsg, WPARAM wParam, LPARAM lParam);
   static BOOL CALLBACK SelectStartupDlgProc(HWND hwnd,UINT uMsg, WPARAM wParam, LPARAM lParam);
   static BOOL CALLBACK SetForegroundHelper(HWND hwnd, LPARAM lParam);         
   static LONG CALLBACK TaskmanDlgProc1(HWND hwnd,UINT uMsg, WPARAM wParam, LPARAM lParam);
   static BOOL CALLBACK TaskmanDlgProc2(HWND hwnd,UINT uMsg, WPARAM wParam, LPARAM lParam);
   static BOOL CALLBACK TaskmanTab1DlgProc(HWND hwnd,UINT uMsg, WPARAM wParam, LPARAM lParam);
   static BOOL CALLBACK TaskmanTab2DlgProc(HWND hwnd,UINT uMsg, WPARAM wParam, LPARAM lParam);   
   
   static LONG  APIENTRY Lv1SubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
   static LONG  APIENTRY Lv2SubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);   
   static VOID ShutdownTerminal();

   friend class CConnectList;

} WBTTASKMAN, *PWBTTASKMAN;

#endif // __WBTSKMN_H__



